﻿<?php 
require_once 'Mail.php';
class MyMail
{
	private $conf = array('host'=>'ssl://smtp.gmail.com','port'=>465,
		'auth'=>true,'username'=>'thesecondgun@gmail.com','password' => '19860601'); 
	private $headers = array('From' => 'thesecondgun@gmail.com', 'Subject' => 'Mustang注册激活');
	private $mail_client;
	public function __construct(){
		$this->mail_client = &Mail::factory('smtp', $this->conf);
	}
	public function send($to, $token){
		$this->headers['To'] = $to;
		$url = "http://localhost:8080/php/activate.php?token=" . $token ;
		$body = "<a href='" . $url ."'>" . $url . "</a>";
		$mail_res = $this->mail_client->send($this->headers['To'], $this->headers, $body);
		if(PEAR::isError($mail_res)){
			echo $mail_res->getMessage();
			return false;
		}else{
			return true;
		}
	}
}
?>